# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html


from qiutan.csv_file import CSV_File

class QiutanPipeline(object):
    def __init__(self):
        self.File = CSV_File()
    def process_item(self, item, spider):
        if hasattr(item, "DATA_TYPE"):
            insert_sql, data, DATA_TYPE = item.get_insert_data()
            self.File.update(data, DATA_TYPE)
            # print(data)
        return item


# class MySql_data_Pipeline(object):
#     def __init__(self):
#         self.db = MySql('localhost', 'root', '123456', 'qiutan', 3306)
#
#     def process_item(self, item, spider):
#         if hasattr(item, 'get_insert_data'):
#             insert_sql, data, DATA_TYPE = item.get_insert_data()
#             self.db.update(insert_sql, data)
#
#         return item

